home *** CD-ROM | disk | FTP | other *** search
- /*
- * Scanline Generation
- * Player Missile Graphics
- * Collision Detection
- * Playfield Priorities
- * Issues cpu cycles during frame redraw.
- */
-
- #include <stdio.h>
- #include <string.h>
-
- #ifndef AMIGA
- #include "config.h"
- #endif
-
- #include "atari.h"
- #include "cpu.h"
- #include "pia.h"
- #include "pokey.h"
- #include "gtia.h"
- #include "antic.h"
- #include "pia.h"
- #include "platform.h"
- #include "pokey11.h"
- #include "mem.h"
- #include "sio.h"
-
- #define FALSE 0
- #define TRUE 1
-
- static char *rcsid = "$Id: gtia.c,v 1.30 1998/02/17 thor,david Exp $";
-
- extern int DELAYED_SERIN_IRQ;
- extern int DELAYED_SEROUT_IRQ;
- extern int DELAYED_XMTDONE_IRQ;
-
- UBYTE COLBK;
- UBYTE COLPF0;
- UBYTE COLPF1;
- UBYTE COLPF2;
- UBYTE COLPF3;
- UBYTE COLPM0;
- UBYTE COLPM1;
- UBYTE COLPM2;
- UBYTE COLPM3;
- UBYTE GRAFM;
- UBYTE GRAFP0;
- UBYTE GRAFP1;
- UBYTE GRAFP2;
- UBYTE GRAFP3;
- UBYTE HPOSP0;
- UBYTE HPOSP1;
- UBYTE HPOSP2;
- UBYTE HPOSP3;
- UBYTE HPOSM0;
- UBYTE HPOSM1;
- UBYTE HPOSM2;
- UBYTE HPOSM3;
- UBYTE SIZEP0;
- UBYTE SIZEP1;
- UBYTE SIZEP2;
- UBYTE SIZEP3;
- UBYTE SIZEM;
- UBYTE PRIOR;
- UBYTE GRACTL;
- UBYTE VDELAY;
- int delayp0,delayp1,delayp2,delayp3; /* VDelay mirrors */
- int delaym0,delaym1,delaym2,delaym3;
- int artefacts;
-
-
- /* Collision stuff. There's no need to mirror the precise hardware registers.
- We keep all the stuff here and extract the information as soon as needed.
-
- Please note that the ordering of these flag fields are a bit strange.
- Namely index #0 relates to missile #3. That is due to the sorting
- of the bits in the missile graphics register for faster access.
- Players, however, are sorted straigh. Wierdos! */
-
- UBYTE Missile_Playfield[4]; /* Missile-playfield collisions */
- UBYTE Missile_Player[4]; /* Missile-player collisions */
- UBYTE Player_Playfield[4]; /* Player-playfield collisions */
- UBYTE Player_Player[4]; /* Player-player collisions */
-
- /* due to the way how the collision detection works currently, not all bits
- are set consistently in these bits. Only higher order players can collide
- with lower order players, missiles with players. It's the task of the
- hardware access registers to gain the right information from these bits.
-
- Player/missile- playfield collisions work straight, though. */
-
- /*
- *****************************************************************
- * *
- * Section : Player Missile Graphics *
- * Original Author : David Firth *
- * Date Written : 28th May 1995 *
- * Version : 1.0 *
- * *
- *****************************************************************
- */
-
- static int global_hposp0;
- static int global_hposp1;
- static int global_hposp2;
- static int global_hposp3;
- static int global_hposm[4]; /* sorted in reverse order, #0 is missile #3 */
- static int global_sizep0;
- static int global_sizep1;
- static int global_sizep2;
- static int global_sizep3;
- static int global_sizem[4];
-
- /*
- =========================================
- Width of each bit within a Player/Missile
- =========================================
- */
-
- static UBYTE pm_scanline[ATARI_MODULO+PLAYER_OFFSET];
-
- UBYTE colour_lookup[9];
- int colour_translation_table[256];
-
- static int GTIA_XLate[]={0,1,2,3,4,5,6,7,8,8,8,8,4,5,6,7};
- static int pf_collision_bit[10] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x02, 0x04, 0x08,
- 0x00, 0x02 /* this last entry is for collisions with the fiddled color */
- };
-
- /* artefact color #1, indexed by the background hue. Must be setup correctly */
- static UBYTE ArteF1[]={0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,
- 0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40};
-
- /* artefact color #2, indexed by the background hue. Still to be done */
- static UBYTE ArteF2[]={0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
- 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90};
-
-
- int next_console_value = 7;
- extern UWORD regPC;
-
- UWORD pl0adr;
- UWORD pl1adr;
- UWORD pl2adr;
- UWORD pl3adr;
- UWORD m0123adr;
-
- static int PM_XPos[256];
- static UBYTE PM_Width[4] = { 2, 4, 2, 8};
- static void Setup_Priority(void);
-
-
- /* Object IDs for the priority engine */
-
- /* First, player and missiles */
- #define ID_PLAYER0 0x10
- #define ID_MISSILE0 0x11
- #define ID_PLAYER1 0x12
- #define ID_MISSILE1 0x13
- #define ID_PLAYER2 0x14
- #define ID_MISSILE2 0x15
- #define ID_PLAYER3 0x16
- #define ID_MISSILE3 0x17
-
- /* Playfield graphics. Some specials for GTIA 0x80 mode - graphics 10 */
- #define ID_PFSP0 0x00
- #define ID_PFSP1 0x01
- #define ID_PFSP2 0x02
- #define ID_PFSP3 0x03
- #define ID_PF0 0x04
- #define ID_PF1 0x05
- #define ID_PF2 0x06
- #define ID_PF3 0x07
- #define ID_PFBACK 0x08
- #define ID_TABLESIZE 0x20
-
-
-
- /* Another implementation of the priority engine */
- static int pl01beatspf; /* true if player 0,1 is on top of pf 0,1 */
- static int pf01beatspl; /* true if playfield 0,1 is on top of player 0,1 */
- static int pl23beatspf; /* true if player 2,3 is on top of pf 2,3 */
- static int pf23beatspl; /* true if playfield 2,3 is on top of player 2,3 */
- static int pl02beatspl; /* true if player 0,2 is on top of player 1,3 */
- static int pfbeatspl; /* true if player 0,1 behind pf 2,3 */
- static int plbeatspf; /* true if player 2,3 in front of pf 0,1 */
- static int misslepf3; /* true if missle 0-3 get pf3 as color */
-
- static void Setup_Priority(void)
- {
- static UWORD lastpri=0xffff;
-
- if (lastpri==PRIOR)
- return;
-
- misslepf3=FALSE;
- pfbeatspl=FALSE;
- plbeatspf=FALSE;
- pl02beatspl=TRUE;
- pf23beatspl=FALSE;
- pl23beatspf=FALSE;
- pf01beatspl=FALSE;
- pl01beatspf=FALSE;
-
- if (PRIOR & 0x10)
- misslepf3=TRUE;
-
- if (PRIOR & 0x20)
- pl02beatspl=FALSE;
-
- if (PRIOR & 0x01) {
- pl01beatspf=TRUE;
- pl23beatspf=TRUE;
- plbeatspf=TRUE;
- }
- if (PRIOR & 0x02) {
- pl01beatspf=TRUE;
- pf23beatspl=TRUE;
- }
- if (PRIOR & 0x04) {
- pf01beatspl=TRUE;
- pf23beatspl=TRUE;
- pfbeatspl=TRUE;
- }
- if (PRIOR & 0x08) {
- pf01beatspl=TRUE;
- pl23beatspf=TRUE;
- }
- }
-
-
- /* Run the priority engine. Get player pixel encoding and
- playfield pixel mask, fiddle is TRUE for the special ANTIC F,2,3 mode
- coloring, i.e. HIRES */
-
- int PixelColor(int pf_pixel,int pm_pixel,int pf_color)
- {
- int pfcol,pfidx;
- int pl0=0,pl1=0,pl2=0,pl3=0;
- int pf0=0,pf2=0;
-
- pfcol=pf_color;
- pfidx=pf_pixel;
- if (pf_pixel==PF_COLPF1_FID) {
- pfcol=colour_lookup[PF_COLPF2];
- pfidx=PF_COLPF2;
- }
-
- if ((pm_pixel & 0xf0) && misslepf3) {
- pfcol=colour_lookup[PF_COLPF3];
- pfidx=PF_COLPF3;
- } else {
- pm_pixel |= pm_pixel>>4;
- }
-
- if (pm_pixel & 0x08) {
- pl3=colour_lookup[PL_COLPL3];
- }
-
- if (pm_pixel & 0x04) {
- pl2=colour_lookup[PL_COLPL2];
- if (pl02beatspl)
- pl3=0;
- }
-
- if (pm_pixel & 0x02) {
- pl1=colour_lookup[PL_COLPL1];
- pl2=pl3=0;
- }
-
- if (pm_pixel & 0x01) {
- pl0=colour_lookup[PL_COLPL0];
- pl2=pl3=0;
- if (pl02beatspl)
- pl1=0;
- }
-
- pl0 |= pl1;
- pl2 |= pl3;
-
- if (pfidx==PF_COLPF0 || pfidx==PF_COLPF1) {
- pf0 = pfcol;
- if (pf01beatspl)
- pl0 = 0;
- if (!plbeatspf)
- pl2 = 0;
- }
-
- if (pfidx==PF_COLPF2 || pfidx==PF_COLPF3) {
- pf2 = pfcol;
- if (pf23beatspl)
- pl2 = 0;
- if (pfbeatspl)
- pl0 = 0;
- }
-
- if (pm_pixel & 0x03) {
- if (pl01beatspf)
- pf0 = 0;
- if (!pfbeatspl)
- pf2 = 0;
- }
-
- if (pm_pixel & 0x0c) {
- if (pl23beatspf)
- pf2 = 0;
- if (plbeatspf)
- pf0 = 0;
- }
-
- pf0 |= pl0;
- pf2 |= pl2;
-
- pfcol = pf0 | pf2;
-
- if (pf_pixel==PF_COLPF1_FID) {
- pfcol = (pfcol & 0xf0) | (colour_lookup[PF_COLPF1] & 0x0f);
- }
-
- return pfcol;
- }
-
- static int missile_mask[4] = {0x80,0x40,0x20,0x10};
-
- void DisplayMissiles(int ofs)
- {
- unsigned int grafm = GRAFM;
- int i,j,sizem=0,mask=0;
- UBYTE *mplc=0,*mpfc=0;
- UBYTE *pmpos=0,*pfpos=0;
-
- for (i=0;i<8;i++) {
- if ((i & 0x01)==0) {
- int ih,hpos;
- ih = i>>1;
- sizem = global_sizem[ih];
- hpos = global_hposm[ih];
- mask = missile_mask[ih];
- mplc = Missile_Player+ih;
- mpfc = Missile_Playfield+ih;
- pmpos = pm_scanline+hpos+PLAYER_OFFSET;
- pfpos = scrn_ptr+hpos+ofs;
- }
-
- if (grafm & 0x80) {
- for (j=0;j<sizem;j++) {
- *mpfc |= pf_collision_bit[*pfpos];
- *mplc |= *pmpos;
- *pmpos |= mask;
- pmpos++;
- pfpos++;
- }
- } else {
- pmpos +=sizem;
- pfpos +=sizem;
- }
- grafm <<= 1;
- }
-
- }
-
- void DisplayPlayer(int ofs,unsigned int graf,int size,int hpos,int num)
- {
- int i,j;
- int coll=0,pmcol=0;
- UBYTE *pmpos,*pfpos;
- int mask;
-
-
- pmpos = pm_scanline + hpos + PLAYER_OFFSET;
- pfpos = scrn_ptr + hpos + ofs;
- mask = 1<<num;
-
- for (i=0;i<8;i++) {
- if (graf & 0x80) {
- for (j=0;j<size;j++) {
- pmcol |= *pmpos;
- *pmpos |= mask;
- coll |= pf_collision_bit[*pfpos];
- pmpos ++;
- pfpos ++;
- }
- } else {
- pmpos += size;
- pfpos += size;
- }
- graf <<= 1;
- }
-
- Player_Playfield[num] |= coll;
- Player_Player[num] |= pmcol;
- }
-
-
- /*
- ======================================
- Player/Missle Graphics service
- routines for different GTIA modes
- ======================================
- */
-
- /* Ordinary display modes */
- void GTIA_Create00(UBYTE *pm,UBYTE *pf,int ofs)
- {
- int xpos;
- int pm_pixel,pf_pixel;
-
- for (xpos=0;xpos<ATARI_WIDTH;xpos++,pm++,pf++) {
-
- pm_pixel = *pm;
- pf_pixel = pf[ofs];
-
- if (pm_pixel) {
- *pf=PixelColor(pf_pixel,pm_pixel,colour_lookup[pf_pixel]) & 0xfe;
- } else {
- if (pf_pixel==PF_COLPF1_FID)
- *pf = (colour_lookup[PF_COLPF1] & 0x0e) | (colour_lookup[PF_COLPF2] & 0xf0);
- else
- *pf = colour_lookup[pf_pixel] & 0xfe;
- }
- }
- }
-
- /* Display with artefacts */
-
- void GTIA_Create00AF(UBYTE *pm,UBYTE *pf,int ofs)
- {
- int xpos;
- int pm_pixel,pf_pixel,last,color,value,hue;
-
- pf_pixel = PF_COLBK;
- for (xpos=0;xpos<ATARI_WIDTH;xpos++,pm++,pf++) {
-
- last = pf_pixel;
- pm_pixel = *pm;
- pf_pixel = pf[ofs];
-
- switch (pf_pixel) {
- case PF_COLPF1_FID:
- value = colour_lookup[PF_COLPF1] & 0x0e;
- hue = colour_lookup[PF_COLPF2] & 0xf0;
- color = value | hue;
- if (last==PF_COLPF2) {
- value += colour_lookup[PF_COLPF2] & 0x0e;
- color=(value>>1) | ((xpos & 0x01)?(ArteF1[hue>>4]):(ArteF2[hue>>4]));
- }
- break;
- case PF_COLPF2:
- hue = colour_lookup[PF_COLPF2] & 0xf0;
- value = colour_lookup[PF_COLPF1] & 0x0e;
- color = colour_lookup[PF_COLPF2] & 0xfe;
- if (last==PF_COLPF1_FID) {
- value += color & 0x0e;
- color=(value>>1) | ((xpos & 0x01)?(ArteF2[hue>>4]):(ArteF1[hue>>4]));
- }
- break;
- default:
- color=colour_lookup[pf_pixel] & 0xfe;
- break;
- }
-
- if (pm_pixel) {
- *pf=PixelColor(pf_pixel,pm_pixel,color) & 0xfe;
- } else {
- *pf = color;
- }
- }
- }
-
- /* Graphics 9 */
- void GTIA_Create40(UBYTE *pm,UBYTE *pf,int ofs)
- {
- int xpos;
- int pm_pixel,pf_pixel=0,nibble=0;
-
- for(xpos=0;xpos<ATARI_WIDTH;xpos++,pm++,pf++) {
-
- pm_pixel = *pm;
-
- if ((xpos & 0x03) == 0x00) {
- nibble = (((pf[ofs+0] & 0x01))<<3)|
- (((pf[ofs+1] & 0x01))<<2)|
- (((pf[ofs+2] & 0x01))<<1)|
- (((pf[ofs+3] & 0x01)));
-
- pf_pixel=colour_translation_table[(COLBK & 0xf0) | nibble];
- }
-
- if (pm_pixel) {
- *pf=PixelColor(PF_COLBK,pm_pixel,pf_pixel);
- } else {
- *pf=pf_pixel;
- }
- }
- }
-
- /* Graphics 10 */
- void GTIA_Create80(UBYTE *pm,UBYTE *pf,int ofs)
- {
- int xpos;
- int pm_pixel,pf_pixel=0,nibble=0;
-
- for(xpos=0;xpos<ATARI_WIDTH;xpos++,pm++,pf++) {
-
- pm_pixel = *pm;
-
- if ((xpos & 0x03) == 0x00) {
- nibble = (((pf[ofs+0] & 0x01))<<3)|
- (((pf[ofs+1] & 0x01))<<2)|
- (((pf[ofs+2] & 0x01))<<1)|
- (((pf[ofs+3] & 0x01)));
-
- pf_pixel=colour_lookup[GTIA_XLate[nibble]];
- }
-
- if (pm_pixel) {
- *pf=PixelColor(nibble,pm_pixel,pf_pixel) & 0xfe;
- } else {
- *pf=pf_pixel & 0xfe;
- }
- }
- }
-
- void GTIA_CreateC0(UBYTE *pm,UBYTE *pf,int ofs)
- {
- int xpos;
- int pm_pixel,pf_pixel=0,nibble=0;
-
- for(xpos=0;xpos<ATARI_WIDTH;xpos++,pf++,pm++) {
-
- pm_pixel = *pm;
-
- if ((xpos & 0x03) == 0x00) {
- nibble = (((pf[ofs+0] & 0x01))<<3)|
- (((pf[ofs+1] & 0x01))<<2)|
- (((pf[ofs+2] & 0x01))<<1)|
- (((pf[ofs+3] & 0x01)));
-
- if (nibble)
- pf_pixel = colour_translation_table[(nibble << 4) | (COLBK & 0x0f)];
- else
- pf_pixel = colour_translation_table[(nibble << 4)];
- }
-
- if (pm_pixel) {
- *pf=PixelColor(PF_COLBK,pm_pixel,pf_pixel) & 0xfe;
- } else {
- *pf=pf_pixel & 0xfe;
- }
-
- }
- }
-
-
- void Atari_ScanLine (int hscrol)
- {
- int ofs=FILLIN_OFFSET;
-
- if (hscrol) {
- ofs -= HSCROL+HSCROL;
- }
-
- POKEY_Scanline();
-
- if (GRAFP0)
- DisplayPlayer(ofs,GRAFP0,global_sizep0,global_hposp0,0);
-
- if (GRAFP1)
- DisplayPlayer(ofs,GRAFP1,global_sizep1,global_hposp1,1);
-
- if (GRAFP2)
- DisplayPlayer(ofs,GRAFP2,global_sizep2,global_hposp2,2);
-
- if (GRAFP3)
- DisplayPlayer(ofs,GRAFP3,global_sizep3,global_hposp3,3);
-
- if (GRAFM)
- DisplayMissiles(ofs);
-
- switch(PRIOR & 0xc0) {
- case 0x00: /* Ordinary display modes */
- if (artefacts)
- GTIA_Create00AF(pm_scanline+PLAYER_OFFSET,scrn_ptr,ofs);
- else
- GTIA_Create00(pm_scanline+PLAYER_OFFSET,scrn_ptr,ofs);
- break;
- case 0x40: /* Graphics 9 */
- GTIA_Create40(pm_scanline+PLAYER_OFFSET,scrn_ptr,ofs);
- break;
- case 0x80: /* Graphics 10 */
- GTIA_Create80(pm_scanline+PLAYER_OFFSET,scrn_ptr,ofs);
- break;
- case 0xc0: /* Graphics 11 */
- GTIA_CreateC0(pm_scanline+PLAYER_OFFSET,scrn_ptr,ofs);
- break;
- }
-
- memset (pm_scanline, 0, ATARI_MODULO+PLAYER_OFFSET);
- }
-
- /* I/O routines for the GTIA */
-
- mtype GTIA_CONSOL_GET(void)
- {
- mtype byte;
-
- if (next_console_value != 7) {
- byte = next_console_value;
- next_console_value = 0x07;
- } else {
- byte = Atari_CONSOL ();
- }
-
- return byte;
- }
-
- /* Missile-Playfield collisions. These are straight, but sorted reverse */
-
- mtype GTIA_M0PF_GET(void)
- {
- /* printf("M0PF %x\n",Missile_Playfield[3]); */
- return Missile_Playfield[3];
- }
-
- mtype GTIA_M1PF_GET(void)
- {
- return Missile_Playfield[2];
- }
-
- mtype GTIA_M2PF_GET(void)
- {
- /* printf("M2PF %x\n",Missile_Playfield[1]); */
- return Missile_Playfield[1];
- }
-
- mtype GTIA_M3PF_GET(void)
- {
- return Missile_Playfield[0];
- }
-
- /* Missile-player collisions. Straight, but sorted in reverse order */
-
- mtype GTIA_M0PL_GET(void)
- {
- return Missile_Player[3] & 0x0f;
- }
-
- mtype GTIA_M1PL_GET(void)
- {
- return Missile_Player[2] & 0x0f;
- }
-
- mtype GTIA_M2PL_GET(void)
- {
- return Missile_Player[1] & 0x0f;
- }
-
- mtype GTIA_M3PL_GET(void)
- {
- return Missile_Player[0] & 0x0f;
- }
-
- /* Player-playfield collisions. Straight. */
-
- mtype GTIA_P0PF_GET(void)
- {
- return Player_Playfield[0];
- }
-
- mtype GTIA_P1PF_GET(void)
- {
- return Player_Playfield[1];
- }
-
- mtype GTIA_P2PF_GET(void)
- {
- return Player_Playfield[2];
- }
-
- mtype GTIA_P3PF_GET(void)
- {
- return Player_Playfield[3];
- }
-
- /* Player-player collisions. Wierd.
- This is simply due to the fact that player zero can't detect collisions with
- other players simply because it is drawn first.
- We've to extract the proper bits from the collison masks of the other
- players and need to "shuffle" a bit here... */
-
- mtype GTIA_P0PL_GET(void)
- {
- int mask=0;
-
- mask = (Player_Player[1] & 0x01)<<1; /* mask in player 1 */
- mask |= (Player_Player[2] & 0x01)<<2; /* mask in player 2 */
- mask |= (Player_Player[3] & 0x01)<<3; /* mask in player 3 */
-
- return mask;
- }
-
- mtype GTIA_P1PL_GET(void)
- {
- int mask=0;
-
- mask = (Player_Player[1] & 0x01); /* mask in player 0 */
- mask |= (Player_Player[2] & 0x02)<<1; /* mask in player 2 */
- mask |= (Player_Player[3] & 0x02)<<2; /* mask in player 3 */
-
- return mask;
- }
-
- mtype GTIA_P2PL_GET(void)
- {
- int mask=0;
-
- mask = (Player_Player[2] & 0x03); /* mask in player 0 and 1 */
- mask |= (Player_Player[3] & 0x04)<<1; /* mask in player 3 */
-
- return mask;
- }
-
- mtype GTIA_P3PL_GET(void)
- {
- int mask=0;
-
- mask = (Player_Player[3] & 0x07); /* mask in player 0,1 and 2 */
-
- return mask;
- }
-
- mtype GTIA_PAL_GET(void)
- {
- if (tv_mode == PAL)
- return 0x01;
- else return 0x0f;
- }
-
- mtype GTIA_TRIG0_GET(void)
- {
- return Atari_TRIG(0);
- }
-
- mtype GTIA_TRIG1_GET(void)
- {
- return Atari_TRIG(1);
- }
-
- mtype GTIA_TRIG2_GET(void)
- {
- return Atari_TRIG(2);
- }
-
- mtype GTIA_TRIG3_GET(void)
- {
- if (machine==Atari) return Atari_TRIG (3);
- else return (CartInserted())?(1):(0);
- }
-
- int GTIA_COLBK_PUT(mtype byte)
- {
- COLBK = byte;
- colour_lookup[8] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPF0_PUT(mtype byte)
- {
- COLPF0 = byte;
- colour_lookup[4] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPF1_PUT(mtype byte)
- {
- COLPF1 = byte;
- colour_lookup[5] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPF2_PUT(mtype byte)
- {
- COLPF2 = byte;
- colour_lookup[6] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPF3_PUT(mtype byte)
- {
- COLPF3 = byte;
- colour_lookup[7] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPM0_PUT(mtype byte)
- {
- COLPM0 = byte;
- colour_lookup[0] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPM1_PUT(mtype byte)
- {
- COLPM1 = byte;
- colour_lookup[1] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPM2_PUT(mtype byte)
- {
- COLPM2 = byte;
- colour_lookup[2] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_COLPM3_PUT(mtype byte)
- {
- COLPM3 = byte;
- colour_lookup[3] = colour_translation_table[byte];
- return FALSE;
- }
-
- int GTIA_GRAFM_PUT(mtype byte)
- {
- GRAFM = byte;
- return FALSE;
- }
-
- int GTIA_GRAFP0_PUT(mtype byte)
- {
- GRAFP0 = byte;
- return FALSE;
- }
-
- int GTIA_GRAFP1_PUT(mtype byte)
- {
- GRAFP1 = byte;
- return FALSE;
- }
-
- int GTIA_GRAFP2_PUT(mtype byte)
- {
- GRAFP2 = byte;
- return FALSE;
- }
-
- int GTIA_GRAFP3_PUT(mtype byte)
- {
- GRAFP3 = byte;
- return FALSE;
- }
-
- int GTIA_HITCLR_PUT(mtype byte)
- {
- memset(Player_Player,0,sizeof(UBYTE)*4);
- memset(Player_Playfield,0,sizeof(UBYTE)*4);
- memset(Missile_Player,0,sizeof(UBYTE)*4);
- memset(Missile_Playfield,0,sizeof(UBYTE)*4);
-
- return FALSE;
- }
-
- int GTIA_HPOSM0_PUT(mtype byte)
- {
- HPOSM0 = byte;
- global_hposm[3] = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_HPOSM1_PUT(mtype byte)
- {
- HPOSM0 = byte;
- global_hposm[2] = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_HPOSM2_PUT(mtype byte)
- {
- HPOSM0 = byte;
- global_hposm[1] = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_HPOSM3_PUT(mtype byte)
- {
- HPOSM0 = byte;
- global_hposm[0] = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_HPOSP0_PUT(mtype byte)
- {
- HPOSP0 = byte;
- global_hposp0 = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_HPOSP1_PUT(mtype byte)
- {
- HPOSP1 = byte;
- global_hposp1 = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_HPOSP2_PUT(mtype byte)
- {
- HPOSP2 = byte;
- global_hposp2 = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_HPOSP3_PUT(mtype byte)
- {
- HPOSP3 = byte;
- global_hposp3 = PM_XPos[byte];
- return FALSE;
- }
-
- int GTIA_SIZEM_PUT(mtype byte)
- {
- SIZEM = byte;
-
- /* We extract now the proper sizes of the missiles. Easier to do here than on
- every scan line since this register isn't written to "too often". */
-
- global_sizem[3] = PM_Width[byte & 0x03];
- global_sizem[2] = PM_Width[(byte >> 2) & 0x03];
- global_sizem[1] = PM_Width[(byte >> 4) & 0x03];
- global_sizem[0] = PM_Width[(byte >> 6) & 0x03];
-
- return FALSE;
- }
-
- int GTIA_SIZEP0_PUT(mtype byte)
- {
- SIZEP0 = byte;
- global_sizep0 = PM_Width[byte & 0x03];
- return FALSE;
- }
-
- int GTIA_SIZEP1_PUT(mtype byte)
- {
- SIZEP1 = byte;
- global_sizep1 = PM_Width[byte & 0x03];
- return FALSE;
- }
-
- int GTIA_SIZEP2_PUT(mtype byte)
- {
- SIZEP2 = byte;
- global_sizep2 = PM_Width[byte & 0x03];
- return FALSE;
- }
-
- int GTIA_SIZEP3_PUT(mtype byte)
- {
- SIZEP3 = byte;
- global_sizep3 = PM_Width[byte & 0x03];
- return FALSE;
- }
-
- int GTIA_PRIOR_PUT(mtype byte)
- {
- PRIOR = byte;
- Setup_Priority();
- return FALSE;
- }
-
- int GTIA_GRACTL_PUT(mtype byte)
- {
- GRACTL = byte;
- return FALSE;
- }
-
- int GTIA_VDELAY_PUT(mtype byte)
- {
- VDELAY = byte;
-
- /* Calculate the delay for each player/missile */
-
- delaym0 = byte;
- delaym1 = byte>>1;
- delaym2 = byte>>2;
- delaym3 = byte>>3;
- delayp0 = byte>>4;
- delayp1 = byte>>5;
- delayp2 = byte>>6;
- delayp3 = byte>>7;
-
- delaym0 &= 0x01;
- delaym1 &= 0x01;
- delaym2 &= 0x01;
- delaym3 &= 0x01;
-
- delayp0 &= 0x01;
- delayp1 &= 0x01;
- delayp2 &= 0x01;
- delayp3 &= 0x01;
-
- return FALSE;
- }
-
- void Init_GTIA(int *argc, char **argv,int base)
- {
- int i,j;
-
- if (argc) {
- artefacts = FALSE;
- for (i=j=1;i<*argc;i++) {
- if (strcmp(argv[i],"-artefacts") == 0)
- artefacts = TRUE;
- else
- argv[j++] = argv[i];
- }
- *argc = j;
- }
-
- for (i=0x00;i<256;i++)
- PM_XPos[i] = (i - 0x20) << 1;
-
- for (i=0;i<9;i++)
- colour_lookup[i] = 0x00;
-
- PRIOR = 0x00;
- Setup_Priority();
-
- SetHW(base+_HPOSP0,0xff1f,>IA_M0PF_GET,>IA_HPOSP0_PUT);
- SetHW(base+_HPOSP1,0xff1f,>IA_M1PF_GET,>IA_HPOSP1_PUT);
- SetHW(base+_HPOSP2,0xff1f,>IA_M2PF_GET,>IA_HPOSP2_PUT);
- SetHW(base+_HPOSP3,0xff1f,>IA_M3PF_GET,>IA_HPOSP3_PUT);
- SetHW(base+_HPOSM0,0xff1f,>IA_P0PF_GET,>IA_HPOSM0_PUT);
- SetHW(base+_HPOSM1,0xff1f,>IA_P1PF_GET,>IA_HPOSM1_PUT);
- SetHW(base+_HPOSM2,0xff1f,>IA_P2PF_GET,>IA_HPOSM2_PUT);
- SetHW(base+_HPOSM3,0xff1f,>IA_P3PF_GET,>IA_HPOSM3_PUT);
- SetHW(base+_SIZEP0,0xff1f,>IA_M0PL_GET,>IA_SIZEP0_PUT);
- SetHW(base+_SIZEP1,0xff1f,>IA_M1PL_GET,>IA_SIZEP1_PUT);
- SetHW(base+_SIZEP2,0xff1f,>IA_M2PL_GET,>IA_SIZEP2_PUT);
- SetHW(base+_SIZEP3,0xff1f,>IA_M3PL_GET,>IA_SIZEP3_PUT);
- SetHW(base+_SIZEM ,0xff1f,>IA_P0PL_GET,>IA_SIZEM_PUT );
- SetHW(base+_GRAFP0,0xff1f,>IA_P1PL_GET,>IA_GRAFP0_PUT);
- SetHW(base+_GRAFP1,0xff1f,>IA_P2PL_GET,>IA_GRAFP1_PUT);
- SetHW(base+_GRAFP2,0xff1f,>IA_P3PL_GET,>IA_GRAFP2_PUT);
- SetHW(base+_GRAFP3,0xff1f,>IA_TRIG0_GET,>IA_GRAFP3_PUT);
- SetHW(base+_GRAFM,0xff1f,>IA_TRIG1_GET,>IA_GRAFM_PUT);
- SetHW(base+_COLPM0,0xff1f,>IA_TRIG2_GET,>IA_COLPM0_PUT);
- SetHW(base+_COLPM1,0xff1f,>IA_TRIG3_GET,>IA_COLPM1_PUT);
- SetHW(base+_COLPM2,0xff1f,>IA_PAL_GET,>IA_COLPM2_PUT);
- SetHW(base+_COLPM3,0xff1f,NULL,>IA_COLPM3_PUT);
- SetHW(base+_COLPF0,0xff1f,NULL,>IA_COLPF0_PUT);
- SetHW(base+_COLPF1,0xff1f,NULL,>IA_COLPF1_PUT);
- SetHW(base+_COLPF2,0xff1f,NULL,>IA_COLPF2_PUT);
- SetHW(base+_COLPF3,0xff1f,NULL,>IA_COLPF3_PUT);
- SetHW(base+_COLBK,0xff1f,NULL,>IA_COLBK_PUT);
- SetHW(base+_PRIOR,0xff1f,NULL,>IA_PRIOR_PUT);
- SetHW(base+_VDELAY,0xff1f,NULL,>IA_VDELAY_PUT);
- SetHW(base+_GRACTL,0xff1f,NULL,>IA_GRACTL_PUT);
- SetHW(base+_HITCLR,0xff1f,NULL,>IA_HITCLR_PUT);
- SetHW(base+_CONSOL,0xff1f,>IA_CONSOL_GET,NULL);
-
- }
-